﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Linq.Expressions;

namespace NhConfig.Expression
{
    public class ExpressionLambda
    {
        public static string GetPropertyName<TResult>(Expression<Func<TResult>> fun)
        {
            var propertyInfo = (fun.Body as MemberExpression).Member as PropertyInfo;
            if (propertyInfo == null)
            {
                throw new ArgumentException("The lambda expression 'property' should point to a valid Property");
            }
            return propertyInfo.Name;

        }
    }
}
